<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        //1、const常量一旦声明其值是固定不变的，如果常量的值是数组或对象则可以改变
        //声明常量:
        const  pi = 3.14;
       // pi = 3.1;  //Assignment to constant variable
       //const pi = 3.1;

        console.log(pi,'pi');

        //如果常量的值是数组或对象则可以改变
        const obj = {x:99,y:100};
        console.log(obj);
        obj.x = 66;
        console.log(obj,'obj');


        //2、同一个常量在同一个作用域只能声明一次
        const host = 'www.qq.com';
        console.log(host);
        //const host = 'www.baidu.com';  //'host' has already been declared


        //3、常量没有提升(也就是常量要先定义后使用)
        //console.log(port);  //port is not defined
        const port = 80;
        console.log(port); 
        
        //4、常量也是块级作用域：
        if(1){
            const tel = 110;
        }

        console.log(tel,'tel');  //tel is not defined

    </script>
</head>
<body>
    
</body>
</html>